
struct Constants
{
    row_major float4x4 View;
    row_major float4x4 ViewProj;
    row_major float4x4 InvView;
    row_major float4x4 InvProj;
    row_major float4x4 InvViewProj;
    float4 CameraPosTime;
    int4 WidthHeight;
    float4 ExposureKd;
};


// float3 GetWorldPos(float3 posC)
// {
//     float4 worldH = mul(constant.InvViewProj, float4(posC, 1));
//     return worldH.xyz / worldH.w;
// }

float2 SampleSphericalMap(float3 v)
{
    v = normalize(v);
    const float2 invAtan = float2(0.1591, 0.3183);
    float2 uv = float2(atan2(v.x, v.z), acos(v.y));
    uv *= invAtan;
    uv.x += 0.5;
    return uv;
}
